/**
 * @file rank/popularize/luogu1071/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/7 17:27:18
 **/

#include <bits/stdc++.h>
using namespace std;
#define dec DEC
typedef long long ll;
typedef vector<int> vi;
char key[256], revkey[256];
const int N = 110;
char enc[N], dec[N], s[N], out[N];
int main() {
  // High rating and good luck!
  cin >> enc >> dec >> s;
  int n = strlen(enc);
  for (int i = 0; i < n; ++i) {
    int a = enc[i], b = dec[i];
    if (key[a] == 0 && revkey[b] == 0) {
      key[a] = b;
      revkey[b] = a;
    } else if (key[a] == b && revkey[b] == a) {
      ;
    } else {
      cout << "Failed\n";
      return 0;
    }
  }
  for (int i = 'A'; i <= 'Z'; ++i) {
    if (key[i] == 0) {
      cout << "Failed\n";
      return 0;
    }
  }
  int m = strlen(s);
  for (int i = 0; i < m; ++i) {
    int a = s[i];
    out[i] = key[a];
  }
  cout << out << endl;
  return 0;
}
